<template>
	<view class="ortherParent">
		<u-navbar title="其他学生信息" :autoBack="true" :placeholder="true">
		</u-navbar>


		<view v-if="showFlag" class="messageContent">
			<view class="messageItem">
				<view class="lable">
					学生姓名
				</view>
				<view class="value">
					{{studentInfo.name || ""}}
				</view>
			</view>
			<view class="messageItem">
				<view class="lable">
					性别
				</view>
				<view class="value">
					{{studentInfo.sex=="0"?"男":"女"}}
				</view>
			</view>
			<view class="messageItem">
				<view class="lable">
					学校
				</view>
				<view class="value">
					{{classInfo.schoolName || ""}}
				</view>
			</view>
			<view class="messageItem">
				<view class="lable">
					年级班级
				</view>
				<view class="value">
					{{classInfo.gradeName || ""}}
					{{classInfo.clazzName || ""}}
				</view>
			</view>
		</view>



		<view v-else class="btns" :class="{btns_student_s:role==1,btns_parent_s:role==2}" @click="handleAddstudent">
			新增
		</view>


	</view>
</template>

<script>
	import {
		getAnotherStudentInfo
	} from "@/api/mine.js"
	export default {
		data() {
			return {
				role: uni.getStorageSync("role"),
				showFlag: false,
				studentInfo: {},
				classInfo: {},
			}
		},
		onShow() {
			this.handlegetAnotherStudentInfo()
		},
		methods: {
			async handlegetAnotherStudentInfo() {
				let res = await getAnotherStudentInfo()
				if (res.code == 200) {
					this.showFlag = res.student ? true : false
					this.studentInfo = res.student || null
					this.classInfo = res.clazz || null
				}

			},
			handleAddstudent() {
				uni.navigateTo({
					url: `/pages/minePackage/addParentMessage/addParentMessage?type=${1}`
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.ortherParent {
		width: 100%;
		min-height: 100vh;
		background-color: #F9F9F9;

		.messageContent {
			width: 100%;

			.messageItem {
				width: 100%;
				padding: 24rpx 32rpx;
				box-sizing: border-box;
				display: flex;
				align-items: center;
				justify-content: space-between;
				background-color: #ffffff;

				.lable {
					font-weight: 550;
					font-size: 28rpx;
					color: #333333;
					line-height: 40rpx;
				}

				.value {
					font-weight: 400;
					font-size: 28rpx;
					color: #333333;
				}

				image {
					width: 48rpx;
					height: 48rpx;
				}

			}

		}

		.btns {
			width: 636rpx;
			height: 80rpx;
			border-radius: 40rpx;
			font-weight: 400;
			font-size: 28rpx;
			line-height: 80rpx;
			text-align: center;
			margin: 30rpx auto;
		}
	}
</style>